import React, { useState, useEffect } from 'react'
import * as api from './server';
import { useHistory } from 'react-router-dom'
import { NavBar } from 'antd-mobile';
const Me = () => {
    const history = useHistory();
    const [user, setUser] = useState([])
    const [newPub, setNewpub] = useState([]);
    useEffect(() => {
        api.getUser('HL1115')
            .then(res => {
                console.log(res.data);
                console.log(res.data.recent_topics)
                setUser(res.data)
                setNewpub(res.data.recent_topics);
            })
    }, [])
    return (
        <div>
            <NavBar onBack={history.goBack} >个人信息</NavBar>
            <h1>Loginname:{user.loginname}</h1>
            <h2>score:{user.score}</h2>
            <h2>最新发布</h2>
            {
                newPub.map(item => {
                    return <li key={item.id}>{item.title}</li>
                })
            }
        </div>
    )
}

export default Me